from src import models
def initialize():
    """
    初始化用户
    :return:
    """
    try:
        user = input("请输入初始化用户>>")
        pwd = input("请输入初始密码>>")
        obj = models.Admin.login(user, pwd)
        if obj:
            return None
        else:
            obj = models.Admin(user, pwd)
            obj.save()
            return True
    except Exception as e:
        print(e)

def main():
    func_list = """
    1.初始化系统
    """
    dist = {
        "1": initialize
    }
    while True:
        print(func_list)
        choice = input("请选择操作选项>>")
        if choice not in dist:
            print("不存在的操作")
            continue
        if dist[choice]():
            print("初始化成功")
            exit()
        else:
            print("用户已经存在")
